home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 081 / mk_user.arc / MK_USER.C next >
Encoding:
C/C++ Source or Header  |  1987-05-30  |  6.2 KB  |  187 lines

  1. #include <stdio.h>
  2. #include <fcntl.h>
  3. #include <sys/types.h>
  4. #include <sys/stat.h>
  5. #include <io.h>
  6. #include "legible.h"
  7.  
  8.  
  9. #define bit unsigned
  10.    
  11. #define  MAXLREAD  0x0a    /* Number of msg area pointers to maintain       */
  12.  
  13.  
  14. /*--------------------------------------------------------------------------*/
  15. /* The USER Structure                                                       */
  16. /*--------------------------------------------------------------------------*/
  17. struct   _usr
  18.    begin
  19.       char name[36];       /* Caller's first and last names                 */
  20.       char city[36];       /* Caller's location                             */
  21.  
  22.       struct {             /* Last message read for the prior 10 areas      */
  23.         word area;
  24.         word msg;
  25.       } lastmsg[MAXLREAD];
  26.  
  27.       char pwd[16];        /* Password                                      */
  28.       word times;          /* Number of previous calls to this system       */
  29.       int  help;           /* Help level (see below)                        */
  30.       word tabs;           /* 0=transmit <sp> instead of <tab>              */
  31.       word nulls;          /* Number of Nulls (delays) after <cr>           */
  32.       word msg;            /* Last message area visited                     */
  33.       bit  filler   : 3;
  34.       bit  use_lore : 1;   /* Use the line-oriented editor */
  35.       bit  more     : 1;   /* Wants the "MORE?" prompt                      */
  36.       bit  ansi     : 1;   /* OPUS: set=wants Ansi                          */
  37.       bit  kludge   : 1;   /* OPUS: set=used Opus before                    */
  38.       bit  formfeed : 1;   /* OPUS: set=transmit <ff>, clear=ignore <ff>    */
  39.       int  priv;           /* Access level (see below)                      */
  40.       char ldate[20];      /* Date of previous date (AsciiZ string)         */
  41.       int  time;           /* Time on-line so-far today                     */
  42.       word flag;           /* Used to hold baud rate on O)utside command    */
  43.       int  upld;           /* K-bytes uploaded, all calls                   */
  44.       int  dnld;           /* K-bytes downloaded, all calls                 */
  45.       int  dnldl;          /* K-bytes downloaded, today                     */
  46.       word files;          /* Last file area visited                        */
  47.       byte width;          /* Width of the caller's monitor                 */
  48.       byte len;            /* Height of the caller's */
  49.       int  credit;
  50.       int  debit;
  51.    end;
  52.  
  53.  
  54.  
  55. /*--------------------------------------------------------------------------*/
  56. /* Access levels                                                            */
  57. /* For information on how these are used in Opus, read the TechRef pamphlet */
  58. /* called REF_PRIV.DOC and the sample control file called OPUS.CTL          */
  59. /*--------------------------------------------------------------------------*/
  60. #define  TWIT        0xFFFE
  61. #define  DISGRACE    0x0000
  62. #define  NORMAL      0x0002
  63. #define  PRIVEL      0x0004
  64. #define  EXTRA       0x0006
  65. #define  ASSTSYSOP   0x0008
  66. #define  SYSOP       0x000A
  67. #define  HIDDEN      0x000B
  68.  
  69.  
  70.  
  71.  
  72. /*--------------------------------------------------------------------------*/
  73. /* User help levels                                                         */
  74. /*--------------------------------------------------------------------------*/
  75. #define  EXPERT      0x02  /* grizzled veteran, no menus at all             */
  76. #define  REGULAR     0x04  /* experienced user, brief menus                 */
  77. #define  NOVICE      0x06  /* Full menus plus additional hand-holding       */
  78.  
  79.  
  80.  
  81. extern int errno;
  82.  
  83. #include <ctype.h>
  84.  
  85.  
  86.  
  87.  
  88. /*--------------------------------------------------------------------------*/
  89. /* FANCY STR                                                                */
  90. /* Standardize the case of a character string                               */
  91. /*--------------------------------------------------------------------------*/
  92. byte *fancy_str( value )
  93.    byte *value;
  94.    begin
  95.       register byte *sptr;
  96.       byte           lower      = 0;
  97.  
  98.       sptr = value;
  99.  
  100.       if (sptr) /* don't touch any NULL pointers */
  101.          while ( *sptr )
  102.             begin
  103.                if (lower) *sptr = tolower( *sptr );
  104.                else *sptr = toupper( *sptr );
  105.  
  106.                lower = ( isalnum( *sptr++ ) );
  107.             end
  108.  
  109.       return( value );
  110.    end /* fancystr */
  111.  
  112.  
  113.  
  114.  
  115. /*--------------------------------------------------------------------------*/
  116. /* MK_USER: main                                                            */
  117. /*--------------------------------------------------------------------------*/
  118. main(argc,argv)
  119.    int    argc;
  120.    char **argv;
  121.    begin
  122.  
  123.       int         fh;
  124.       struct _usr usr;
  125.  
  126.       cputs("MK_USER. Creates a User.Bbs file.\r\n");
  127.  
  128.       if (argc!=4)
  129.          begin
  130.             cputs("ERROR.  Usage: MK_USER firstname lastname password\r\n");
  131.             exit(1);
  132.          end
  133.  
  134.       memset( (char *)&usr, 0, sizeof(struct _usr) );
  135.  
  136.       sprintf( usr.name, "%s %s", argv[1], argv[2] );
  137.       if (strlen(usr.name)>35)
  138.          begin
  139.             cputs("FIRST+LAST names must be 35 chars. or shorter.");
  140.             exit(1);
  141.          end
  142.       fancy_str(usr.name);
  143.  
  144.       strcpy( usr.pwd, argv[3] );
  145.       if (strlen(usr.pwd)>15)
  146.          begin
  147.              cputs("PASSWORD must be 15 chars. or shorter.");
  148.             exit(1);
  149.          end
  150.       fancy_str(usr.pwd);
  151.  
  152.       usr.help = NOVICE;
  153.       usr.priv = SYSOP;
  154.       usr.len  = 23;
  155.       usr.width= 79;
  156.  
  157.  
  158.       errno = 0;
  159.       fh    = open("USER.BBS",O_CREAT|O_EXCL|O_BINARY|O_WRONLY,S_IREAD|S_IWRITE);
  160.       if ((errno) or (fh<0))
  161.          begin
  162.              perror("Can't create USER.BBS");
  163.             exit(1);
  164.          end
  165.  
  166.  
  167.       write(fh, (char *)&usr, sizeof(struct _usr) );
  168.       if (errno)
  169.          begin
  170.              perror("Error writing USER.BBS");
  171.             exit(1);
  172.          end
  173.  
  174.       close(fh);
  175.       if (errno)
  176.          begin
  177.              perror("Error closing USER.BBS");
  178.             exit(1);
  179.          end
  180.  
  181.       cputs("USER.BBS created.\r\n");
  182.       cprintf("Hello, %s.  Welcome to Opus-CBCS.\r\n", argv[1] );
  183.  
  184.    end
  185.  
  186.  
  187.